<?php
namespace App\Admin\Models;
use Common\BaseModel;
class CollegeCollect extends BaseModel
{
    protected $res;
    protected $key="admin_";
    public function initialize()
    {
        parent::initialize();
        $this->setSource('f_college_study');
    }



    /**
     * 当前内容的个人的收藏量
     */
    public function find_count($carousel_id,$user_id=0){
        $conditions ='';
        if($user_id){
            $conditions = "user_id={$user_id}";
        }
        if($carousel_id){
            if($conditions){
                $conditions="carousel_id={$carousel_id}";
            }else{
                $conditions="user_id={$user_id} AND carousel_id={$carousel_id}";
            }
        }
        $count_number = $this::count(
            array(
                $conditions,
                "cloumns"=>'id',
                "limit"=>1,
            )
        );
        return $count_number;
    }


    /**
     * 获取具体的内容
     * @param int $cid 栏目id
     * @param int $cateid 分类id
     * @param int $is_recommend 是否首页推荐
     * @return mixed
     */
    public function find_list($cid=0,$cateid=0,$is_recommend=0){
        $conditions='is_show=1';
        if($cid){
            $conditions .= " AND cid={$cid}";
        }
        if($cateid){
            $conditions .= " AND cateid={$cateid}";
        }
        if($is_recommend){
            $conditions .= " AND is_recommend={$is_recommend}";
        }
        $order="id ASC,sort ASC";
        $user_list = $this::find(
            array(
                $conditions,
                "order" => $order,
            )
        )->toarray();
        return $user_list;
    }





}
